package com.yunbao.hujin.myzoomcenter;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.Toast;

import com.yunbao.hujin.myzoomcenter.banner_two.BannerView;
import com.yunbao.hujin.myzoomcenter.banner_two.utils.DisplayUtil;

import java.util.ArrayList;
import java.util.List;

/**
 * banner Two
 */
public class BannerTwoActivity extends AppCompatActivity {

    BannerView banner;
    List<String> pics = new ArrayList<>();

    int bannerHeight = (int) (DisplayUtil.getInstance().mWidthPix * 0.4453);

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_banner_two);

        banner = findViewById(R.id.banner);
        setBanner();
    }

    private void setBanner() {
        pics.add("http://www.apkbus.com/data/attachment/forum/201710/23/122713c5p5msalrxazdnbb.jpg");
        pics.add("http://p0.ifengimg.com/pmop/2017/1022/76A0A483055FBA896F2DD37605FF68B5A74B7346_size240_w950_h543.jpeg");
        pics.add("http://www.apkbus.com/data/attachment/forum/201708/24/154313el6i0y06yqhyqh63.png");
//        pics.add("http://www.apkforum/201708/24/154313el6i0y06yqhyqh63.png");//错误图片地址


//        LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, bannerHeight);
//        banner.setLayoutParams(layoutParams);
        banner.setViewUrls(pics, null);

        banner.setOnBannerItemClickListener(new BannerView.OnBannerItemClickListener() {
            @Override
            public void onItemClick(int position) {
                Toast.makeText(BannerTwoActivity.this, pics.get(position).substring(0, 20), Toast.LENGTH_SHORT).show();
            }
        });
    }


    @Override
    protected void onResume() {
        super.onResume();
//        banner.setFocusable(true);
//        banner.setFocusableInTouchMode(true);
//        banner.requestFocus();
    }
}
